package com.cgy.utils.base.fusing.setting;

import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
import lombok.Getter;
import lombok.Setter;

/**
 * 
 * @author CH
 */
@Getter
@Setter
public class FusingCommandSetting {
	/**
	 * z是否启用熔断器,默认true. 启动
	 */
	private Boolean circuitBreakerEnabled = null;
    /**
     * z是否允许熔断器忽略错误,默认false, 不开启
     */
    private Boolean circuitBreakerForceClosed = null;
    /**
     * z是否强制开启熔断器阻断所有请求,默认:false,不开启。置为true时，所有请求都将被拒绝，直接到fallback
     */
    private Boolean circuitBreakerForceOpen = null;
    /**
     * z熔断器在整个统计时间内是否开启的阀值，默认20。
     * z也就是在metricsRollingStatisticalWindowInMilliseconds（默认10s）内至少请求20次，熔断器才发挥起作用
     * circuitBreakerRequestVolumeThreshold = 3时,10s中有3个请求,直接进入降级fallback
     */
    private Integer circuitBreakerRequestVolumeThreshold = null;
    /**
     * z默认:50%。当出错率超过50%后熔断器启动
     * circuitBreakerErrorThresholdPercentage = 80时,超时请求占所有请求比例>80%时开始熔断
     */
    private Integer circuitBreakerErrorThresholdPercentage = null;
    /**
     * z熔断时间窗口，默认:5秒.
     * z熔断器中断请求5秒后会进入半打开状态,放下一个请求进来重试，如果该请求成功就关闭熔断器，否则继续等待一个熔断时间窗口
     */
    private Integer circuitBreakerSleepWindowInMilliseconds = null;
    /**
     * z使用命令调用隔离方式,默认:采用线程隔离,ExecutionIsolationStrategy.THREAD
     * z信号量隔离(ExecutionIsolationStrategy.SEMAPHORE)
     * z配置信号量线程池配置无效
     */
    private ExecutionIsolationStrategy executionIsolationStrategy = null;
    /**
     * z使用信号量隔离时，命令调用最大的并发数,默认:10
     * executionIsolationSemaphoreMaxConcurrentRequests = 3时,当请求数超过3会触发降级不执行run而执行fallback
     */
    private Integer executionIsolationSemaphoreMaxConcurrentRequests = null;
    /**
     * z使用线程隔离时，是否对命令执行超时的线程调用中断（Thread.interrupt()）操作.默认:true
     */
    //private Boolean executionIsolationThreadInterruptOnTimeout = null;
    //private Boolean executionIsolationThreadInterruptOnFutureCancel = null;
    //private Integer executionTimeoutInMilliseconds = null;
    //private Boolean executionTimeoutEnabled = null;
    /**
     * z使用信号量隔离时，命令fallback(降级)调用最大的并发数,默认:10
     * fallbackIsolationSemaphoreMaxConcurrentRequests = 1时,超过则抛出异常fallback execution rejected
     */
    private Integer fallbackIsolationSemaphoreMaxConcurrentRequests = null;
    /**
     * z是否开启fallback降级策略 默认:true
     */
    private Boolean fallbackEnabled = null;
   // private Integer metricsHealthSnapshotIntervalInMilliseconds = null;
   // private Integer metricsRollingPercentileBucketSize = null;
    /**
     * z是否开启监控统计功能,默认:true
     */
    private Boolean metricsRollingPercentileEnabled = null;
    /**
     * z统计滚动的时间窗口,默认:5000毫秒
     */
    private Integer metricsRollingPercentileWindowInMilliseconds = null;
    /**
     * z统计窗口的Buckets的数量,默认:10个,每秒一个Buckets统计
     */
    private Integer metricsRollingPercentileWindowBuckets = null;
    //private Integer metricsRollingStatisticalWindowInMilliseconds = null;
   // private Integer metricsRollingStatisticalWindowBuckets = null;
    /**
     * z是否开启请求缓存,默认:true 
     */
    private Boolean requestCacheEnabled = null;
    /**
     * z是否开启请求日志,默认:true
     */
    private Boolean requestLogEnabled = null;
    /**
     * z请求合并是允许的最大请求数,默认: Integer.MAX_VALUE
     */
    private Integer maxRequestsInBatch = null;

    private Integer executionTimeoutInMilliseconds = null;
	
}
